﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TemplateEmailSender
{
    static class Template
    {
        public static List<string> menu = new List<string>();
        public static string file;
        public static string output;
        public static void GetTemplate(string templatePath)
        {
            StreamReader template = new StreamReader(templatePath);
            using (template)
            {

                file = template.ReadToEnd();
            }
        }
        
        public static void GetClumnNamesFromTemplate()
        {
            menu.Clear();
            char c;
            int currentPosition = 0;
            StringBuilder temp = new StringBuilder();
            bool record = false;
            List<string> tempMenu = new List<string>();
            while (currentPosition < file.Length)
            {

                c = file[currentPosition];
                if (c == '[')
                {
                    record = true;
                    currentPosition++;
                    continue;
                }
                if (c == ']')
                {
                    record = false;
                    tempMenu.Add(temp.ToString());
                    temp.Clear();
                    currentPosition++;
                    continue;
                }
                if (record)
                {
                    temp.Append(c);
                }
                currentPosition++;
            }
            menu = tempMenu.Distinct().ToList();
        }

    }
}
